#include <vector>
#include <cmath>

using namespace std;

class Solution
{
public:
    int countKDifference(vector<int> &nums, int k)
    {
        int ret = 0;
        int slow = 0, fast = 1;
        while (slow < nums.size())
        {
            for (fast = slow + 1; fast < nums.size(); ++fast)
            {
                if (abs(nums[fast] - nums[slow]) == k)
                {
                    ++ret;
                }
            }
            slow++;
        }
        return ret;
    }
};